import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.SocketException;

public class Service {
    public static void main(String[] args) throws Exception {
        System.out.println("服务端启动了");
        DatagramSocket socket = new DatagramSocket(6666);
        byte[] bytes = new byte[1024*64];//创建一个字符节

        //创造有参构造器
        DatagramPacket datagramPacket = new DatagramPacket(bytes,bytes.length);
        //开始接受客户端的消息
        socket.receive(datagramPacket);//DatagramSocket中的receive是接受信心，与客户端中的send是相对应的
        //获取本次接受了多少数据；
        int len = datagramPacket.getLength();
        String s = new String(bytes,0,len );
        System.out.println(s);
        System.out.println("服务端");
        socket.close();

    }
}
